<template>
  <div>
    <group title="系统设置">
      <selector title="微信号:" placeholder="请选择微信号" :options="wrList" v-model="wxId" @on-change="Change"></selector>
      <x-input title="微信UIN:" :value="uin" placeholder="微信号对应的UIN" novalidate :icon-type="iconType" :show-clear="false" @on-blur="onBlur" placeholder-align="right"></x-input>
    </group>
  </div>
</template>
<script>
  import { Selector, XInput, Group, Cell } from 'vux'

  export default {
    components: {
      XInput,
      Selector,
      Group,
      Cell
    },
    mounted: function () {
      this.uin = localStorage.uin
      this.wxId = localStorage.wxId
      this.$http.get('/wx/WxRobotController.do?getWechatRotInfo&uin=all')
        .then(function (res) {
          let l = res.body.result
          let wrList = []
          let wrMap = new Map()
          l.forEach(function (value, index, array) {
            wrList.push(value.wechatNickName)
            wrMap.set(value.wechatNickName, value.wechatUin)
          })
          console.log(wrMap)
          this.wrList = wrList
          this.wrMap = wrMap
        }, function (res) {
          console.log(res)
        })
    },
    methods: {
      Change (val) {
        if (typeof (val) === 'undefined') {
          return
        }
        localStorage.uin = this.wrMap.get(val)
        localStorage.wxId = val
        this.uin = this.wrMap.get(val)
      }
    },
    data () {
      return {
        uin: '',
        wxId: String,
        wrList: [],
        wrMap: Object
      }
    }
  }

</script>

<style scoped>


</style>
